var htmlload = "<table style='width:100%;height:100%;'><tr><td style='text-align:center;'><img src='images/bigloading.gif' alt=''/></td></tr></table>";
var htmlmoneyout = "<div>提现金额:<input type='text' />&nbsp;&nbsp;最小提现金额<span>" + sysConfigMinMoneyOut + "</span>元</div><div>提现密码:<input type='password' />&nbsp;&nbsp;每日最多提现2次</div><div><input type='submit' class='ui-state-hover' value='提交' onclick='moneyOut()' /><span id='errorMsgMoney' class='greenfont'></span></div>";
$(function() {
    //初始化充提窗口
    //$("#div_dialog_money").dialog({ autoOpen: false, resizable: false, show: "slide", hide: "slide" });
}); 
function showMoneyDialog() {
    $("#div_dialog_money").dialog("option", "title", "提现");
    $("#div_dialog_money").html(htmlmoneyout);
    if (!$("#div_dialog_money").dialog("isOpen")) {
        $("#div_dialog_money").dialog("open");
    }
    setTimeout('$("#div_dialog_money input[type=text]").focus()', 500);       //获取焦点
}

function moneyOut() {
    showMoneyErrorMsg("");
    var amount = parseFloat($("#div_dialog_money input[type=text]").val());
    if (isNaN(amount)) {
        showMoneyErrorMsg("金额输入有误");
        $("#div_dialog_money input[type=text]").select()
        return;
    }
    if (amount > userInfo.AmountLave()) {
        showMoneyErrorMsg("余额不足，无法提现");
        $("#div_dialog_money input[type=text]").select()
        return;
    }
    if (amount < sysConfigMinMoneyOut) {
        showMoneyErrorMsg("提现金额不能低于" + sysConfigMinMoneyOut + "元");
        $("#div_dialog_money input[type=text]").select()
        return;
    }
    var password = $("#div_dialog_money input[type=password]").val();
    if (password == "") {
        showMoneyErrorMsg("提现密码输入有误");
        $("#div_dialog_money input[type=password]").select()
        return;
    }
    $("#div_dialog_money").dialog("option", "title", "提现处理中.....");
    $("#div_dialog_money").html(htmlload);
    $.post("ajax_moneyout.aspx", { amount: amount, password: password }, completeMoneyOut);
}
function completeMoneyOut(data) {
    $("#div_dialog_money").dialog("option", "title", "提现");
    $("#div_dialog_money").html(htmlmoneyout);
    if (data == "") {
        showMoneyErrorMsg("操作异常，请重试");
        return;
    }
    var rv;
    try {
        eval("rv=" + data);
    }
    catch (e) {
        showMoneyErrorMsg("操作异常，请重试");
        return;
    }
    showMoneyErrorMsg(rv.msg);
    if (rv.status) {
        //成功
        $("#div_dialog_money input[type=text]").val("");
        $("#div_dialog_money input[type=password]").val("");
        getUserInfo();
    }
}
function showMoneyErrorMsg(msg) {
    $("#errorMsgMoney").html(msg);
}